package com.gxa.insurance.service.impl;

import com.gxa.insurance.exception.BusinessException;
import com.gxa.insurance.exception.ExceptionCode;
import com.gxa.insurance.mapper.CardMapper;
import com.gxa.insurance.mapper.InsuranceOrderMapper;
import com.gxa.insurance.pojo.InsuranceOrder;
import com.gxa.insurance.service.InsuranceOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @date 2022/6/14
 */
@Service("insuranceOrderService")
@Transactional(rollbackFor = Throwable.class)
public class InsuranceOrderServiceImpl implements InsuranceOrderService {

    @Autowired
    CardMapper cardMapper;



    @Autowired
    InsuranceOrderMapper insuranceOrderMapper;

    @Override
    public Integer add(InsuranceOrder insuranceOrder) throws BusinessException {

        Integer add = insuranceOrderMapper.add(insuranceOrder);

        if (add == 0){

            throw new BusinessException(ExceptionCode.INSERT_FILED);
        }

        return add;
    }
}
